<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Phar File Format</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="phar.fileformat.zip.html">« Zip-based phars</a></li>
      <li style="float: right;"><a href="phar.fileformat.flags.html">Global Phar bitmapped flags »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="phar.fileformat.html">What makes a phar a phar and not a tar or a zip?</a></li>
    <li>Phar File Format</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="phar.fileformat.phar" class="section">
 <h2 class="title">Phar File Format</h2>
 <p class="para">
  The phar file format is literally laid out as stub/manifest/contents/signature, and
  stores the crucial information of what is included in the phar archive in its
  <code class="literal">manifest</code>.
 </p>
 <p class="para">
  The Phar manifest is a highly optimized format that allows per-file
  specification of file compression, file permissions, and even user-defined
  meta-data such as file user or group.  All values greater than 1 byte are stored
  in little-endian byte order, with the exception of the API version, which
  for historical reasons is stored as 3 nibbles in big-endian order.
 </p>
 <p class="para">
  All unused flags are reserved for future use, and must not be used
  to store custom information.  Use the per-file meta-data facility
  to store customized information about particular files.
 </p>
 <p class="para">
  The basic file format of a Phar archive manifest is as follows:
 </p>
 <p class="para">
 <table class="doctable table">
  <caption><strong>Global Phar manifest format</strong></caption>
  
   <thead>
    <tr>
     <th>Size in bytes</th>
     <th>Description</th>
    </tr>

   </thead>

   <tbody class="tbody">
    <tr>
     <td>4 bytes</td>
     <td>Length of manifest in bytes (1 MB limit)</td>
    </tr>

    <tr>
     <td>4 bytes</td>
     <td>Number of files in the Phar</td>
    </tr>

    <tr>
     <td>2 bytes</td>
     <td>API version of the Phar manifest (currently 1.0.0)</td>
    </tr>

    <tr>
     <td>4 bytes</td>
     <td>Global Phar bitmapped flags</td>
    </tr>

    <tr>
     <td>4 bytes</td>
     <td>Length of Phar alias</td>
    </tr>

    <tr>
     <td>??</td>
     <td>Phar alias (length based on previous)</td>
    </tr>

    <tr>
     <td>4 bytes</td>
     <td>Length of Phar metadata (<code class="literal">0</code> for none)</td>
    </tr>

    <tr>
     <td>??</td>
     <td>Serialized Phar Meta-data, stored in <span class="function"><a href="function.serialize.html" class="function">serialize()</a></span> format</td>
    </tr>

    <tr>
     <td>at least 24 * number of entries bytes</td>
     <td>entries for each file</td>
    </tr>

   </tbody>
  
 </table>

 </p>
</div></div></div></body></html>